<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/layui-2.4.2/src/css/layui.css">
    <script type="text/javascript" src="/jquery/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="/layui-2.4.2/src/layui.js"></script>
</head>
<body>
<div>
    <div class="layui-row">

    </div>
</div>
<div>
    <form class="layui-form" action="" style="display:none;">
        <div class="layui-form-item">
            <label class="layui-form-label">商品名称</label>
            <div class="layui-input-block">
                <input type="text" name="productName" lay-verify="productName" autocomplete="off" placeholder="请输入商品名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">商品价格</label>
            <div class="layui-input-block">
                <input type="text" name="price" placeholder="请输入商品价格" class="layui-input">
            </div>
        </div>
    </form>
</div>

</body>
<script type="text/javascript">
    layui.use(['table','form','laytpl'],function() {
        var table=layui.table;
        var layer=layui.layer;
        var form=layui.form;
        form.verify({
            productName: function(value){
                if(value.length >20){
                    return '商品名称长度不能超过20';
                }
            }
        });

        $('#add_account').on('click',function(){
            editAccountFunc();
        });
        var editAccountFunc=function () {
            layer.open({
                type:1,
                title:'编辑账号',
                area:['600px','400px'],
                content:$("#edit_form"),
                btn:['保存','取消'],
                btnALign:'c',
                yes:function(index,layero){
                    $.ajax({
                        type:'post',
                        data:$('#edit_form').serialize(),
                        url:'/account/save',
                        cache:false,
                        dataType:'json',
                        success:function(data){
                            layer.closeAll();
                            $(".layui-laypage-btn").click()
                        }
                    });
                },
                end:function(){
                    $("#accountName").removeAttr('disabled','');
                    $("#accountName").css('background-color','');
                    $("#account_id").val('');
                    $("#accountName").val('');
                    $("#accountRealName").val('');
                    $("#email").val('');
                    $("#mobilePhone").val('');
                    layer.closeAll();

                }
            });


        }

    });


</script>
</html>